package com.example.design;

import java.util.ArrayList;
import java.util.List;

/**
 * 泛型
 * @author xiaohf
 * @createTime 2021/9/10 11:18
 **/
public class OOPGenericityTest {
    public static void main(String[] args) {
        //继承
        Dog dog = new Dog("旺财",4);

        //多态
        Animal cat = new Cat();

        //泛型
        Zoo<Animal> animalZoo = new Zoo<>();

        animalZoo.addObjectAnimal("1");
        animalZoo.addObjectAnimal(3);


        animalZoo.addAnimal(cat);
        animalZoo.addAnimal(dog);
    }
}



class Zoo<E>{

    List<E> animals = new ArrayList<>();

    List objectAnimals = new ArrayList();

    public void addAnimal(E e) {
        animals.add(e);
    }

    public void addObjectAnimal(Object o) {
        objectAnimals.add(o);
    }
}


